From 4fa97663e74ccf0660f891ade47c95f872169274 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 22 Aug 2011 08:12:10 +0000 Subject: [PATCH] Make the language recaching non-recursive and load the data directly. This might be a bit slower, but avoids problems with cyclic language fallbacks. Followup r94907 --- includes/LocalisationCache.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index b20db3298a..96b377592b 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -514,6 +514,7 @@ class LocalisationCache { foreach ( $data as $key => $value ) { $this->mergeItem( $key, $coreData[$key], $value ); } + } # Fill in the fallback if it's not there already @@ -532,17 +533,24 @@ class LocalisationCache { } # Load the fallback localisation item by item and merge it - foreach ( $coreData['fallbackSequence'] as $fallback ) { - $deps = array_merge( $deps, $this->getItem( $fallback, 'deps' ) ); + foreach ( $coreData['fallbackSequence'] as $fbCode ) { + + # Load the secondary localisation from the source file to + # avoid infinite cycles on cyclic fallbacks + $fbFilename = Language::getMessagesFileName( $fbCode ); + if ( !file_exists( $fbFilename ) ) continue; + + $deps[] = new FileDependency( $fbFilename ); + $fbData = $this->readPHPFile( $fbFilename, 'core' ); foreach ( self::$allKeys as $key ) { + if ( !isset( $fbData[$key] ) ) continue; if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) { - $fallbackValue = $this->getItem( $fallback, $key ); - $this->mergeItem( $key, $coreData[$key], $fallbackValue ); + $this->mergeItem( $key, $coreData[$key], $fbData[$key] ); } } } - } + $codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] ); # Load the extension localisations -- 2.20.1